package com.dc.toolkit.json_fastjson.bo;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Data
@NoArgsConstructor
@Accessors(chain = true)
public class Person {

    /**
     * id
     *
     * - @JSONField(ordinal = 1)            序列化字段的顺序，默认是0
     * - @JSONField(name = "ID")            用于转换后或解析前的字段名称
     */
    @JSONField(ordinal = 1, name = "ID")
    private Integer id;
    /**
     * 名字
     */
    @JSONField(ordinal = 2)
    private String name;
    /**
     * 年龄
     */
    @JSONField(ordinal = 3)
    private Integer age;

    /**
     * 生日
     * - @JSONField(format = "yyyy-MM-dd")   用于 Date转Json的格式，或者 前端传 Json时间转Date
     */
    @JSONField(ordinal = 4, format = "yyyy-MM-dd")
    private LocalDate brithday;

    @JSONField(ordinal = 5)
    private List<String> list;

    @JSONField(ordinal = 6)
    private Map<String, String> map;

    /**
     * 是否删除
     * - @JSONField(serialize = false)      是否要把这个字段序列化成JSON字符串，默认是true
     * - @JSONField(deserialize = false)    是否要把这个字段序列化成JSON字符串，默认是true
     */
    @JSONField(serialize = false, deserialize = false)
    private Boolean isDel;


    public Person(Integer id, String name, Integer age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public Person(Integer id, String name, Integer age, LocalDate brithday, Boolean isDel) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.brithday = brithday;
        this.isDel = isDel;
    }
}
